package video;

import org.json.JSONObject;

public class Video {
    private int aid;     // av number
    private String author;
    private String tname;   // categories
    private int coin;       // number of coins
    private int favorites;  // number of favorites

    public Video(JSONObject video) {
        aid = video.getInt("aid");
        author = video.getString("author");
        tname = video.getString("tname");
        coin = video.getJSONObject("stat").getInt("coin");
        favorites = video.getInt("favorites");
    }

    public Video(int aid, String author, String tname, int coin, int favorites) {
        this.aid = aid;
        this.author = author;
        this.tname = tname;
        this.coin = coin;
        this.favorites = favorites;
    }

    public int getAid() {
        return aid;
    }

    public String getAuthor() {
        return author;
    }

    public String getTname() {
        return tname;
    }

    public int getCoin() {
        return coin;
    }

    public int getFavorites() {
        return favorites;
    }

    public void display() {
        System.out.println(aid + "\t" + author + "\t" + tname
                + "\t" + coin + "\t" + favorites);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Video video = (Video) o;

        return aid == video.getAid();
    }

    @Override
    public int hashCode() {
        return aid;
    }
}
